<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'Zcwt.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/plugins/sweetalert/sweetalert.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/bootstrap.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

<link rel="shortcut icon" href="${pageContext.request.contextPath}/hplus/favicon.ico">
<link href="${pageContext.request.contextPath}/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="${pageContext.request.contextPath}/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="${pageContext.request.contextPath}/hplus/css/animate.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">


<script type="text/javascript"
	src="${pageContext.request.contextPath}/laydate/laydate.js"></script>

  </head>
  <style>
  	body{
  		padding-top:20px;
  		padding-left:5px;
  		padding-right:5px;
  	}
  	#div1{
  		margin-bottom: 20px;
  	}
  	.kai{
  		width:200px;
  		height:30px;
  	}
  	.wei{
  		width:200px;
  		height:30px;
  	}
  </style>
	<script>
	
	$(function(){
		$("#jvForm2").submit(function(){
			var ok = $("#ok").val();
			if(ok == 0){
				alert("请选择是否解决");
				return false;
			}
			location.reload(true);
		})
	})
	
		function time(){
			var date = new Date();
						var seperator1 = "-";
						var year = date.getFullYear();
						var month = date.getMonth() + 1;
						var strDate = date.getDate();
						if (month >= 1 && month <= 9) {
							month = "0" + month;
						}
						if (strDate >= 0 && strDate <= 9) {
							strDate = "0" + strDate;
						}
						var time = year + seperator1 + month + seperator1 + strDate;
						return time;
		}
	
		function uploadPic(){
			
				var name = $("#name").val();
				var namet = $("#namet").val();
				var ok = $("#ok").val();
				var remark = $("#remark").val();
				var yin3 = $("#yin3").val();
				if(ok==0){
					alert("请选择是否解决");
					return false;
				}
				$.post("pmate.do?met=add",{"name":name,'namet':namet,"ok":ok,"remark":remark,"yin3":yin3},function(){
					
					
				})
				var o;
				if(ok==1){
					o="已解决";
				}else if(ok==2){
					o="未解决";
				}
				var hao = "<tr>"+
					    			"<td class='a'>"+time()+"</td>"+
					    			"<td class='b'>"+name+"</td>"+
					    			"<td class='c'>"+namet+"</td>"+
					    			"<td class='d'>"+o+"</td>"+
					    			"<td class='e'>"+remark+"</td>"+
					    			"<td onclick='xiu(this)'>修改</td>"+
					    		"</tr>";
					$('#dd').after(hao);
				$("#myModal").modal("hide");
				console.log(name);
				console.log(namet);
				console.log(ok);
				console.log(remark);
				console.log(yin3);
		}
		
		
		var oo ;
		
		function xiu(obj,id){
			var s = $(obj).parent();
			var a = s.children(".a").text();
			var b = s.children(".b").text();
			var c = s.children(".c").text();
			var d = s.children(".d").text();
			var e = s.children(".e").text();
			oo=s;
			
			$("#myModal2").modal("show");
			$("#name2").val(b);
			$("#namet2").val(c);
			if(d=="已解决"){
				$("#ok2").val(1);
			}else{
				$("#ok2").val(2);
			}
			
			$("#remark2").val(e);
			$("#yin9").val(id);
		}
		function uploadPic2(){
			
				var name = $("#name2").val();
				var namet = $("#namet2").val();
				var ok = $("#ok2").val();
				var ban;
				if(ok==1){
					ban="已解决";
				}else if(ok==2){
					ban="未解决"
				}
				console.log(ok);
				var remark = $("#remark2").val();
				var yin9 = $("#yin9").val();
				var yin3 = $("#yin3").val();
				if(ok==0){
					alert("请选择是否解决");
					return false;
				}
				$.post("pmate.do?met=update",{"name":name,'namet':namet,"ok":ban,"remark":remark,"yin9":yin9,"yin3":yin3},function(){
					
					
				})
				var b = oo.children(".b").text(name);
				var ban;
				if(ok==1){
					ban="已解决";
				}else if(ok==2){
					ban="未解决"
				}
				console.log(ban);
				var c = oo.children(".c").text(namet);
				var d = oo.children(".d").text(ban);
				var e = oo.children(".e").text(remark);
				$("#myModal2").modal("hide");
				
		}
		$(function(){
			laydate.render({
  				elem: '#s1'
			});
			laydate.render({
	  			elem: '#s2' //指定元素
			});
			var jiahao = $("#jiahao").val();
			console.log(jiahao);
			if(jiahao==3){
				$("#ri").remove();
			}
		
		})
	</script>
  	
  <body>
  <input type="hidden" id="jiahao" value="${jiahao }" />
  <div id="div1" style="float:left;">
		<button type="button" class="btn"
			onclick="location='baoshow.jsp'">后退</button>
		<button type="button" class="btn"
			data-toggle="modal" data-target="#myModal">添加问题
		</button>
	</div>
	<div id="ri" style="float:right">
		<form action="pmate.do">
		<input type="hidden" name="met" value="123" />
			<input type="text" class="kai" name="kai" id="s1" placeholder="请选择开始时间">
			  到
		    <input type="text" class="wei" name="wei" id="s2" placeholder="请选择结束时间">
		   <button type="submit" class="btn">查询</button>
		</form>
			
	</div>
    <table class="table table-striped">
    	<tr id="dd">
    		<th>日期</th>
    		<th>标题</th>
    		<th>主材问题</th>
    		<th>是否解决</th>
    		<th>备注（解决方法）</th>
    		<th>操作</th>
    	</tr>
    	<c:forEach items="${list }" var="list">
    		<tr>
    			<td class="a">${list.time }</td>
    			<td class="b">${list.headline }</td>
    			<td class="c">${list.mmpro }</td>
    			<td class="d">${list.nott }</td>
    			<td class="e">${list.remark }</td>
    			<td onclick="xiu(this,${list.id})">修改</td>
    		</tr>
    	</c:forEach>
    </table>
    
    
    <!-- Modal -->
		<div class="modal fade" id="myModal">
			<div class="modal-dialog" style="width:600,height:303px;"
				role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">添加辅材问题问题</h4>
					</div>
					<div class="modal-body">
						<!-- form开始 -->
						<form id="jvForm2" action="pmate.do?met=add" method="post"
							>
							<div class="form-group">
							
								<label for="name2" style="float: left;">标题:</label> <input
									type="text" class="form-control" id="name"
									placeholder="请输入标题名称" name="name">
									<input type="hidden" id="yin3" value="${id}" name="yin3" />
							</div>
							<div class="form-group">
								<label for="namet" style="float: left;">主要问题:</label> <input
									type="text" class="form-control" id="namet"
									placeholder="请输入主要问题" name="namet">
							</div>
							<div class="form-group">
								<label for="ok" style="float: left;">是否解决</label> 
								<select id ="ok" class="form-control" name="ok">
									<option value="0">请选择</option>
									<option value="1">已解决</option>
									<option value="2">未解决</option>
								</select>
							</div>
							<div class="form-group">
								<label for="remark" style="float: left;">备注（解决方法）:</label> <input
									type="text" class="form-control" id="remark"
									placeholder="请输入解决方法" name="remark">
							</div>
						</form>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button onclick="uploadPic()" type="button"
							class="btn btn-primary">添加</button>
					</div>
				</div>
			</div>
		</div>
		
		
		
		<!-- Modal -->
		<div class="modal fade" id="myModal2">
			<div class="modal-dialog" style="width:600,height:303px;"
				role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">修改辅材问题</h4>
					</div>
					<div class="modal-body">
						<!-- form开始 -->
						<form id="jvForm2" action="" method="post"
							>
							<input type="hidden" id="yin4" value="${id}" name="yin3" />
							<div class="form-group">
							<input type="hidden" id="yin9" />
								<label for="name2" style="float: left;">标题:</label> <input
									type="text" class="form-control" id="name2"
									placeholder="请输入标题名称" name="name">
									<input type="hidden" id="yin3" value="${id}" name="yin3" />
							</div>
							<div class="form-group">
								<label for="namet" style="float: left;">主要问题:</label> <input
									type="text" class="form-control" id="namet2"
									placeholder="请输入主要问题" name="namet">
							</div>
							<div class="form-group">
								<label for="ok" style="float: left;">是否解决</label> 
								<select id ="ok2" class="form-control" name="ok">
									<option value="0">请选择</option>
									<option value="1">已解决</option>
									<option value="2">未解决</option>
								</select>
							</div>
							<div class="form-group">
								<label for="remark" style="float: left;">备注（解决方法）:</label> <input
									type="text" class="form-control" id="remark2"
									placeholder="请输入解决方法" name="remark">
							</div>
						</form>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button onclick="uploadPic2()" type="button"
							class="btn btn-primary">修改</button>
					</div>
				</div>
			</div>
		</div>
    
  </body>
</html>
